//
//  ExtensionListCell.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/12/19.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "ExtensionListCell.h"

@interface ExtensionListCell ()

/// viewModle
@property (nonatomic, readwrite, strong) ExtensionListCellModel *viewModel;

/// IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* cityLabel;
@property (weak, nonatomic) IBOutlet UILabel* dateLabel;
@property (weak, nonatomic) IBOutlet UIButton* renewBtn;

@end

@implementation ExtensionListCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma mark - bind data
- (void)bindViewModel:(ExtensionListCellModel *)viewModel
{
    self.viewModel = viewModel;
    
    @weakify(self);
    
    self.cityLabel.text = self.viewModel.city;
    self.dateLabel.text = HCStrFormat(@"到期时间: %@", self.viewModel.date);
    
    [[self.renewBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x)
    {
        @strongify(self);
        
        [self.viewModel.renewCommand execute:nil];
    }];
}

@end
